package com.yubest.designpattern.create.singleton;

/**
 * 双重校验锁-线程安全
 *
 * @Author: hweiyu
 * @Date: 2022/10/26 10:40
 */
public class DoubleCheckLockLazySingleton {

    private volatile static DoubleCheckLockLazySingleton instance;

    private DoubleCheckLockLazySingleton() {
    }

    public static DoubleCheckLockLazySingleton getInstance() {
        if (instance == null) {
            synchronized (DoubleCheckLockLazySingleton.class) {
                if (instance == null) {
                    instance = new DoubleCheckLockLazySingleton();
                }
            }
        }
        return instance;
    }
}
